<:!:/>
<!--
// @formatter:off
/**
 * @file c.edituser.html
 * @author Alejandro Dario Simi
 * @date $Date: 2013-03-31 09:33:18 +0000 (Sun, 31 Mar 2013) $
 *
 * $Id: c.edituser.html 60 2013-03-31 09:33:18Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.2/themes/default/templates/contents/c.edituser.html $
 */
// @formatter:on
--><::/><script type="text/javascript">
	var hash = "<:VAR:!:/>PASSRESET<::/>";

	function ChangePassword() {
		var password0 = $("#PASSWORD0").val().trim();
		var password1 = $("#PASSWORD1").val().trim();
		var password2 = $("#PASSWORD2").val().trim();

		if( (password0.length > 0 || hash.length > 0) && password1.length > 0 && password1 == password2) {
			jQuery.post("service.php?action=<:VAR:/>WC_SERVICE_USERS<::/>", {
				'MODE': 'password',
				'USER': '<:VAR:/>id<::/>',
				'HASH': hash,
				'PASSWORD': password0,
				'NEWPASSWORD': password1
			}, function(data) {
				var xml = $($.parseXML(data));
				if(xml.find("wc-success").length) {
					alert("Your password was successfully changed.");
					<:ISSET:var=PASSRESET:/>ReloadHome<::/><:ISSET:!:var=PASSRESET:/>SelfReload<::/>();
				} else if(xml.find("wc-failed").length) {
					var error = "";
					if(xml.find("wc-error>wc-code").length) {
						error = "[" + xml.find("wc-error>wc-code").text() + "] ";
					}
					error = error + xml.find("wc-error>wc-message").text();

					alert("Failed: " + error);
				}
			});
		} else if(password0.length == 0 && hash.length == 0) {
			$("#PASSWORD0").focus();
			alert("You must enter your current password");
		} else if(password1.length == 0) {
			$("#PASSWORD1").focus();
			alert("You must enter a new password");
		} else if(password2 != password1) {
			$("#PASSWORD2").focus();
			alert("Password retry doesn't match");
		}

		return false;
	}

	function UpdateInfo() {
		var bData = Object();
		var xData = Object();

		bData["FULLNAME"] = $("#FULLNAME").val().trim();
		bData["EMAIL"] = $("#EMAIL").val().trim();

		$('[id^="UXD_"]').each(function(){
			xData[$(this).attr("id").substr(4)] = $(this).val();
		});

		jQuery.post("service.php?action=<:VAR:/>WC_SERVICE_USERS<::/>", {
			MODE: 'update',
			USER: '<:VAR:/>id<::/>',
			BASICS: bData,
			DATA: xData
		}, function(data) {
			var xml = $($.parseXML(data));
			if(xml.find("wc-success").length) {
				alert("Information successfully updated.");
				SelfReload();
			} else if(xml.find("wc-failed").length) {
				var error = "";
				if(xml.find("wc-error>wc-code").length) {
					error = "[" + xml.find("wc-error>wc-code").text() + "] ";
				}
				error = error + xml.find("wc-error>wc-message").text();

				alert("Failed: " + error);
			}
		});

		return false;
	}
//<:ISSET:var=ADMIN:/>
	function AdminUpdate() {
		var gData = Object();

		$('[id^="ADM_GROUP_"]').each(function(){
			gData[$(this).attr("id").substr(10)] = $(this).val();
		});

		jQuery.post("service.php?action=<:VAR:/>WC_SERVICE_USERS<::/>", {
			MODE: 'adm-update',
			USER: '<:VAR:/>id<::/>',
			GROUPS: gData
		}, function(data) {
			var xml = $($.parseXML(data));
			if(xml.find("wc-success").length) {
				alert("Information successfully updated.");
				SelfReload();
			} else if(xml.find("wc-failed").length) {
				var error = "";
				if(xml.find("wc-error>wc-code").length) {
					error = "[" + xml.find("wc-error>wc-code").text() + "] ";
				}
				error = error + xml.find("wc-error>wc-message").text();

				alert("Failed: " + error);
			}
		});

		return false;
	}
//<::/>
</script>
<:ISSET:!:var=PASSRESET:/><form id="UsernameForm" class="Formulary" action="#" onsubmit="UpdateInfo();return false;" method="post">
	<table><tr>
		<td class="Title" colspan="2"><span class="Title">User Information</span></td>
	</tr><tr>
		<td class="Info" colspan="2"><p>This is your basic information held in our system.</p></td>
	</tr><tr>
		<td class="Label">Username</td>
		<td class="Value"><input class="Full" type="text" id="USERNAME" value="<:VAR:/>username<::/>" disabled="disabled"/></td>
	</tr><tr>
		<td class="Label">Full Name</td>
		<td class="Value"><input class="Full" type="text" id="FULLNAME" value="<:VAR:/>fullname<::/>"/></td>
	</tr><tr>
		<td class="Label">e-mail</td>
		<td class="Value"><input class="Full" type="text" id="EMAIL" value="<:VAR:!:/>email<::/>"/></td>
	<:OVER:list=extradata:/></tr><tr>
		<td class="Label"><:VAR:/>USX_TITLE<::/></td>
		<td class="Value">
			<:IF:var=USX_TYPE:value=unknown:/><input class="Full" type="text" id="UXD_<:VAR:/>USX_NAME<::/>" value="<:VAR:/>USX_VALUE<::/>"/><::/>
			<:IF:var=USX_TYPE:value=list:/><select id="UXD_<:VAR:/>USX_NAME<::/>">
				<:OVER:list=USX_VALUES:key=item:/><option value="<:VAR:/>item<::/>"<:IF:var=item:to=USX_VALUE:/> selected="selected"<::/>><:VAR:/>item<::/></option><::/>
			</select><::/>
		</td><::/>
	<:ISSET:!:var=ADMIN:/><:OVER:list=groups:/></tr><tr title="Permission over group '<:VAR:/>name<::/>'">
		<td class="Label">Group '<:VAR:/>name<::/>'</td>
		<td class="Value"><:VAR:/>selected<::/></td><::/><::/>
	</tr><tr>
		<td colspan="2" class="Buttons">
			<input type="submit" value="Save"/>
			<input type="reset"  value="Clear Changes"/>
		</td>
	</tr></table>
</form><::/>

<form id="PasswordForm" class="Formulary" action="#" onsubmit="ChangePassword();return false;" method="post">
	<:ISSET:var=PASSRESET:/><input type="hidden" id="PASSWORD0" value=""/><::/>
	<table><tr>
		<td class="Title" colspan="2"><span class="Title">Password</span></td>
	</tr><tr>
		<td class="Info" colspan="2"><p>This form allows you to change your password.</p></td>
	<:ISSET:!:var=PASSRESET:/></tr><tr>
		<td class="Label">Current Password</td>
		<td class="Value"><input class="Full" type="password" id="PASSWORD0" value=""/></td><::/>
	</tr><tr>
		<td class="Label">New Password</td>
		<td class="Value"><input class="Full" type="password" id="PASSWORD1" value=""/></td>
	</tr><tr>
		<td class="Label">Password Retry</td>
		<td class="Value"><input class="Full" type="password" id="PASSWORD2" value=""/></td>
	</tr><tr>
		<td colspan="2" class="Buttons">
			<input type="submit" value="Change Password"/>
			<input type="reset"  value="Clear"/>
		</td>
	</tr></table>
</form>
<:ISSET:var=ADMIN:/>
<form id="AdminForm" class="Formulary FormularyAdmin" action="#" onsubmit="AdminUpdate();return false;" method="post">
	<table><tr>
		<td class="Title" colspan="2"><span class="Title">User Administration</span></td>
	</tr><tr>
		<td class="Info" colspan="2"><p>
			Since you have enough clearance, you are able to use this
			form to alter this user access.
		</p></td>
	<:OVER:list=groups:/></tr><tr title="Permission over group '<:VAR:/>name<::/>'">
		<td class="Label">Group '<:VAR:/>name<::/>'</td>
		<td class="Value"><select id="ADM_GROUP_<:VAR:/>id<::/>">
			<:OVER:list=profiles:key=code:/><option value="<:VAR:/>code<::/>"<:IF:var=selected:to=code:/> selected="selected"<::/>><:VAR:/>code<::/></option><::/>
		</select></td><::/>
	</tr><tr>
		<td colspan="2" class="Buttons">
			<input type="submit" value="Save"/>
			<input type="reset"  value="Clear Changes"/>
		</td>
	</tr></table>
</form><::/>